HipDecisionTree

DecisionTree intuition:

IsVisible: true-> Returns PlayerMovement.run false-> Returns a new branch if is hearing IsHearing: true-> Returns "They're hearing you!" false-> Returns null

Functions receive a void* context for accepting any data You can set true or false results for branches by executing the following code tree.setTrueBranch("IsVisible.no.IsHearing", ConditionResult.create("They're hearing you!");

This will make the true branch result at isVisible(false branch) gets the value of the string.

Basic example on how the decision tree works:

HipDecisionTree playerAI = new HipDecisionTree("Enemy-based PlayerAI");

playerAI.addCondition(Condition("IsVisible", (void* ctx) { PlayerAIDecision* d = cast(PlayerAIDecision*)ctx; writeln("Checking if visible"); return d.isVisible; })); playerAI.setTrueBranch("IsVisible", ConditionResult.create(cast(int)PlayerMovement.run)) .setFalseBranch("IsVisible", ConditionResult.create(Condition("IsHearing", (void* ctx) { PlayerAIDecision* d = cast(PlayerAIDecision*)ctx; return d.isHearing; }) )); playerAI.setTrueBranch("IsVisible.no.IsHearing", ConditionResult.create("They're hearing you!"));

PlayerAIDecision d; d.isVisible = false; d.isHearing = false; ConditionResult res = playerAI.check("IsVisible", &d); if(res.type == ResultTypes._int) { writeln(*cast(int*)res.value); } else if(res.type == ResultTypes._string) { writeln(*cast(string*)res.value); }

Constructors

this
this(string name)
Undocumented in source.

Members

Functions

addCondition
HipDecisionTree addCondition(Condition c)
Undocumented in source. Be warned that the author may not have intended to support it.
check
ConditionResult check(string which, void* ctx)
Undocumented in source. Be warned that the author may not have intended to support it.
getConditionByName
Condition* getConditionByName(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
setFalseBranch
HipDecisionTree setFalseBranch(string conditionName, ConditionResult res)
Undocumented in source. Be warned that the author may not have intended to support it.
setTrueBranch
HipDecisionTree setTrueBranch(string conditionName, ConditionResult res)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

conditions
Condition[string] conditions;
Undocumented in source.
name
string name;
Undocumented in source.

Meta